<%@ page contentType="text/html; charset=UTF-8"%>
<%@page import="com.biz.conf.Global"%>
<%@ include file="/jsp/taglib.jsp"%>
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>商品详情</title>
<meta name="description" content="这是一个 首页面">
<meta name="keywords" content="index">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

	<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
	<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
	<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
	<script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/ajaxfileupload.js"></script>
<style>
    .form-group{
        margin:5px 0;
    }
    ul,li,ol{
        list-style-type: none;
        padding-left: 0;
    }
    .clear{
        clear: both;
    }
</style>
</head>
  <!-- content end -->
<input type="hidden" name="types" id="form_id">
<input type="hidden" name="paymentRoute" id="paymentRoute" value="0">
<input type="hidden" name="types" id="obje_id">
<input type="hidden" name="types" id="obje_orderstate">
<input type="hidden" name="types" id="order_state">
	<div class="admin-content" style="overflow-y:auto;">

		<form class="" id="form" name="form">
            <div class="" id="form_remove">
                <div class="">

                    <div class="form-group clear">
                        <div class="col-xs-2 col-sm-2">订单编号：</div>
                        <div class="col-xs-10 col-sm-10">
                            <span id="select_code"></span>
                        </div>
                    </div>
                    <div class="form-group clear">
                        <div class="col-xs-2 col-sm-2">申请金额：</div>
                        <div class="col-xs-10 col-sm-10">
                            <span id="select_money"></span>
                        </div>
                    </div>
                    <div class="form-group clear">
                        <div class="col-xs-2 col-sm-2">申请原因：</div>
                        <div class="col-xs-10 col-sm-10">
                            <span  id="select_note"></span>
                        </div>
                    </div>
                    <div class="form-group clear">
                        <div class="col-xs-2 col-sm-2">凭证图片：</div>
                        <div class="col-xs-10 col-sm-10">
                            <div id="ulpiclist"></div>

                        </div>
                    </div>

                    <div class="form-group clear">
                        <div class="col-xs-2 col-sm-2">审批备注：</div>
                        <div class="col-xs-10 col-sm-10">
                            <textarea rows="3" style="width:100%;" id="select_remarks"></textarea>
                        </div>
                    </div>
                </div>

            </div>
		</form>
        <div class="col-sm-12 col-sm-12 text-center  clear">
            <button type="button" class="btn btn-primary"
                    onclick="order_sp(2,'是否确定审批通过？');">同意</button>
            <button type="button" class="btn btn-primary"
                    onclick="order_sp(3,'是否确定审批退回？');">拒绝</button>
        </div>
    </div>

<body>
<script>
	var id=${id};
    var detailId="${detailId}";
	var picPath='<%=Global.getConfig("OSSURL")%>/';
	var picPathType3='<%=Global.getConfig("OSSURL_mainType3")%>/';
    var index = parent.layer.getFrameIndex(window.name);
	$(function(){
       var type ='${type}';
        console.log(type);
        if(type=="od") {
            loadOrderDetails();
        }else if(type=="sp") {
            loadRefundDetails();
        }
	});

    function loadRefundDetails(){
        $.ajax({
            url : '${pageContext.request.contextPath}/order/orderRefundObject.ac',
            type : "post",
            data : {
                orderId : detailId
            },
            dataType : "json",
            success : function(data) {
                var orderRefund=data.orderRefund;
                var piclist=data.piclist;
                $("#select_code").html(orderRefund.code);
                $("#select_money").html(orderRefund.money);
                $("#select_note").html(orderRefund.note);
                $("#obje_id").val(orderRefund.id);
                $("#form_id").val(detailId);
                $("#obje_orderstate").val(orderRefund.orderstate);
                $("#paymentRoute").val(orderRefund.paymentRoute);


                var htmlpic='';
                htmlpic +='<ul class="floatlili" >';
                jQuery.each(piclist, function(i, val) {
                    htmlpic +='<li><img src="'+picPath+ val.path + '" height="80" /></li>';
                });

                htmlpic += '<br class="clear" /></ul>';
                $("#ulpiclist").html(htmlpic);
            }
        });
    }

	function loadOrderDetails()
	{
		var url="${pageContext.request.contextPath}/order/findOrderInfoById.ac?id="+id+"&detailId="+detailId;
		$.get(url,function(data){
			var res=JSON.parse(data);
			$("#orderId").html(res.code);

         /*   if(res.isGroup==3){
                $("#isGroup").html("体验店");
            }else{
                $("#isGroup").html("商城");
            }*/
            $("#isGroup").html("商城");
			$("#payCode").html(res.payCode);
			$("#createTime").html(res.createTime);
            if(!(res.orderSend==undefined || res.orderSend==null)){
                $("#fullName").html(res.orderSend.recPersonName);
            }

			$("#addr").html(res.pro+res.city+res.area+res.buyAddr);
	if(res.listDetail[0].buyNotes==null||res.listDetail[0].buyNotes==undefined)
	{res.listDetail[0].buyNotes='';}
			$("#buyerNote").html('<span class="changefont">买家留言：</span>'+res.listDetail[0].message);
			var goodsMoneyHtml = '';
            $("#orderType").html('普通订单');
			/*if(res.isGroup=='0')
			{$("#orderType").html('普通订单');}
			else if(res.isGroup=='1')
			{$("#orderType").html('团购订单');}
*/

			/*if(res.paymentRoute=='0')
			{$("#payWay").html('余额支付');}
			else if(res.paymentRoute=='1')
			{$("#payWay").html('银联支付');}
			else if(res.paymentRoute=='2')
			{$("#payWay").html('支付宝支付');}
			else if(res.paymentRoute=='3')
			{$("#payWay").html('微信支付');}
			else if(res.paymentRoute=='4')
			{$("#payWay").html('其他支付');}*/
            if(!(res.orderSend==undefined || res.orderSend==null)){
                if (res.orderSend.sendType == '0') {
                    $("#sendWay").html('物流配送');
                }
                else if (res.orderSend.sendType == '1') {
                    $("#sendWay").html('自己配送');
                }
                $("#sendPhone").html(res.orderSend.userphone);
            }
			var htmlGive='';
			/*if(res.giveType=="0")
			{htmlGive+='赠予要求：送自己,';}
			else
			{htmlGive+='赠予要求：送他人,'+'买家手机号：'+res.givePhone+',';}
			if(res.giveMsg!=null&&res.giveMsg!=undefined&&res.giveMsg!='')
			{htmlGive+='特殊要求：'+res.giveMsg;}
			else
			{htmlGive+='特殊要求：无';}*/
			$("#giveMessage").html(htmlGive);
			
		/*	if(res.isMessage=="0")
			{$("#hkMessage").html("贺卡留言：无");}
			else
			{$("#hkMessage").html("贺卡留言："+res.message);}
			*/
			var htmlTime='';
			var otherMoney='';
			htmlTime+='<div>下单时间：<span>'+res.createTime+'</span></div>';
			if(res.payTime!=null&&res.payTime!=''&&res.payTime!=undefined)
			{
				htmlTime+='<div>支付时间：<span>'+res.payTime+'</span></div>';	
			}
            if(!(res.orderSend==undefined || res.orderSend==null)){
                if (res.orderSend.sendTime != null && res.orderSend.sendTime != '' && res.orderSend.sendTime != undefined) {
                    htmlTime += '<div>发货时间：<span>' + res.orderSend.sendTime + '</span></div>';
                }
                if (res.orderSend.confirmTime != null && res.orderSend.confirmTime != '' && res.orderSend.confirmTime != undefined) {
                    htmlTime += '<div>签收时间：<span>' + res.orderSend.confirmTime + '</span></div>';
                }
            }
			if(res.orderRefund!=null)
			{
				if(res.orderRefund.createTime!=null&&res.orderRefund.createTime!=''&&res.orderRefund.createTime!=undefined)
				{
					htmlTime+='<div>退款申请时间：<span>'+res.orderRefund.createTime+'</span></div>';	
				}
				
				if(res.orderRefund.applyTime!=null&&res.orderRefund.applyTime!=''&&res.orderRefund.applyTime!=undefined)
				{
					htmlTime+='<div>退款审核时间：<span>'+res.orderRefund.applyTime+'</span></div>';	
				}
				if (res.orderRefund.state==1){
					htmlTime+= '<button class="btn btn-xs btn-danger"  onclick="ToExamine(\''+res.orderRefund.orderId+'\');">待审批</button>';
				} else if(res.orderRefund.state==2)  {
					htmlTime+= "<font color='green'>申请通过</font>";
				}else if(res.orderRefund.state==3)  {
					htmlTime+= "<font color='green'>申请退回</font>";
				}
				if(res.orderRefund.state=="1")
				{otherMoney+='  退款金额：￥'+res.orderRefund.money+'(待审批)';}
				else if(res.orderRefund.state=="2")
				{otherMoney+='  退款金额：￥'+res.orderRefund.money+'(已通过)';}
				else if(res.orderRefund.state=="3")
				{otherMoney+='  退款金额：￥'+res.orderRefund.money+'(已拒绝)';}
			}
			else{
				otherMoney+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			}
			$("#liushui").html(htmlTime);
			$("#otherMoney").html(otherMoney);
			
			//<div>申请退款时间：<span>2016-6-23 11:22:33</span></div>
        	var htmlGoods='';
        	$(res.listDetail).each(function(i){
        		htmlGoods+='<tr>'+
        		'<td style="text-align:left;">'+
        		'<div class="am-u-sm-12 am-pad-none">'+
        		'<div class="am-u-sm-4">';
				if(res.listDetail[i].mainType == '3'){
					htmlGoods+='<img src="'+picPathType3+res.listDetail[i].path+'" width="100px" height="100px"/>';
				}else{
					htmlGoods+='<img src="'+picPath+res.listDetail[i].path+'" width="100px" height="100px"/>';
				}
				htmlGoods+='</div>';
				htmlGoods+=' <div class="am-u-sm-8">'+
        		'<div>'+res.listDetail[i].goodsName+'</div>'+
        		'<div>'+res.listDetail[i].typeName1+'</div>'+
        		'<div>'+res.listDetail[i].typeName2+'</div>'+
        		'<div>'+res.listDetail[i].typeName3+'</div>'+
        		'</div></div></td>';
        		if(res.listDetail[i].goodsType == '0')
        		{
        			if(res.listDetail[i].price != undefined)
        			{
        				htmlGoods+='<td>'+res.listDetail[i].price+'券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span></td>';
        			}else{
        				htmlGoods+='<td>0券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span></td>';
        			}
        		}else{
        			htmlGoods+='<td>'+res.listDetail[i].couponsPayTotal+'元</td>';
        		}
        		htmlGoods+='<td>'+res.listDetail[i].count+'</td>';
        		
        		if(res.listDetail[i].goodsType == '0')
        		{
        			if(res.listDetail[i].couponsPayTotal != undefined)
        			{
        				htmlGoods+='<td>'+res.listDetail[i].couponsPayTotal+'券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span></td>';
        			}else{
        				htmlGoods+='<td>0券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span></td>';
        			}
        		}else{
        			htmlGoods+='<td>'+res.listDetail[i].couponsPayTotal+'元</td>';
        		}
        		if(i==0)
        		{
        			htmlGoods+=' <td rowspan="2" >'+res.freightTotal+'</td>';
        			if(res.listDetail[i].goodsType == '0')
	        		{
	        			if(res.listDetail[i].couponsPayTotal != undefined)
	        			{
	        				htmlGoods+='<td rowspan="2" >'+res.listDetail[i].couponsPayTotal+'券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span></td>';
	        				goodsMoneyHtml+='<span class="changefont"> 商品总额：</span>'+res.listDetail[i].price+'券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span>'+'  实收金额：'+res.listDetail[i].couponsPayTotal+'券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span>';
	        			}else{
	        				htmlGoods+='<td rowspan="2" >0券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span></td>';
	        				goodsMoneyHtml+='<span class="changefont"> 商品总额：</span>'+res.listDetail[i].price+'券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span>'+'  实收金额：0券<span>(含服务费'+res.listDetail[i].payTotal+'元)</span>';
	        			}
	        		}else{
	        			htmlGoods+='<td rowspan="2" >'+res.listDetail[i].couponsPayTotal+'元</td>';
	        			goodsMoneyHtml+='<span class="changefont"> 商品总额：</span>￥'+res.goodsTotal+'  <span class="changefont"> 实收金额：</span>￥'+res.payTotal;
	        		}
        		}
        		if(res.listDetail[i].state=="0")
    			{htmlGoods+=' <td>待付款</td>';}
    			else if(res.listDetail[i].state=="1")
    			{htmlGoods+=' <td>待发货</td>';}
    			else if(res.listDetail[i].state=="2")
    			{htmlGoods+=' <td>已发货</td>';}
    			else if(res.listDetail[i].state=="3")
    			{htmlGoods+=' <td>待评价</td>';}
    			else if(res.listDetail[i].state=="4")
    			{htmlGoods+=' <td>已完成</td>';}
    			else if(res.listDetail[i].state=="5")
    			{htmlGoods+=' <td>退款中</td>';}
    			else if(res.listDetail[i].state=="6")
    			{htmlGoods+=' <td>已退款</td>';}
    			else if(res.listDetail[i].state=="7")
    			{htmlGoods+=' <td>待备货</td>';}
    			else if(res.listDetail[i].state=="8")
    			{htmlGoods+=' <td>未备货退款</td>';}
        		htmlGoods+='</tr>';
        	});
        	
        	$("#goodsMoney").html(goodsMoneyHtml);
        	$("#tbodyHtml").html(htmlGoods);
		});
	}


	function order_sp(state, msg) {
		$("#orderspmsg").html(msg);
		$("#order_state").val(state);

        var title = state==2?"您确定同意退款吗？":"您确定拒绝退款吗？";
        swal({
            title: title,
            text: "操作后将无法恢复，请谨慎操作！",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确认",
            closeOnConfirm: false
        }, function () {
            saveYesNo();
        });
	}	//审批通过或退回

	function saveYesNo() {
		var state = $("#order_state").val();
		var obje_id = $("#obje_id").val();
		var remarks = $("#select_remarks").val();
		var orderid = $("#form_id").val();
		var orderstate =  $("#obje_orderstate").val();
        var paymentRoute = $("#paymentRoute").val();
		$.ajax({
					url : '${pageContext.request.contextPath}/order/orderRefundSp.ac',
					type : "post",
					data : {
						id : obje_id,
						state : state,
						remarks : remarks,
						orderid:orderid,
                        orderstate:orderstate,
                        paymentRoute:paymentRoute
					},
					dataType : "json",
					success : function(data) {
						if (data=='success') {

                            swal("操作成功！","", "success");
                            parent.layer.close(index);
						} else {
                            swal("操作失败！","", "fail");
						}
					}
				});
	}
</script>         
</body>

</html>
